const express = require('express')
const app = express();
// 引入mysql的依赖模块
const mysql = require('mysql');
// 创建mysql的链接池
const db = mysql.createPool({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: '123456',
    database: 'shopdb'
})
app.get('/list', (req, res) => {
    let sql = "update t_goods set price=3999 where id=?"//修改语句
   // 增加  // "insert into t_goods values(5,'IQOO[12+256G直降100]',null,'./images/05.png',3999)"
    //删除 // "delete from t_goods where id=5" 
    //查找 // 'select * from t_goods'
    // 调用query方法访问数据库，[]为请求的参数，result是数据库的响应数据
    db.query(sql, [1], (err, result) => {
        res.send(result)
    })
})


app.listen(3001, () => {
    console.log("sever is running at port 3001!");
})